package com.example.springaop2.proxy;

import com.example.springaop2.realSubject.RealHouseSubject;
import com.example.springaop2.subject.HouseSubject;

public class HouseProxy implements HouseSubject {
    //将被代理对象声明为成员变量
    private HouseSubject subject;

    public HouseProxy(RealHouseSubject realHouseSubject) {
        this.subject = realHouseSubject;
    }

    @Override
    public void rentHouse() {
        System.out.println("我是中介，开始代理");
        subject.rentHouse();
        System.out.println("我是中介，结束代理");
    }

    @Override
    public void saleHouse() {
        System.out.println("我是中介，开始代理");
        subject.saleHouse();
        System.out.println("我是中介，结束代理");
    }
}
